home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / bbs / mxgui203.zip / GUI_FONT.TXT < prev    next >
Text File  |  1997-08-12  |  8KB  |  157 lines

  1. {
  2. ───────────────────────────────────────────────────────────────────────────────
  3.   ▀▀▀   ▀▀▀   ▀▀▀▀▀   ▀▀   ▀▀
  4.   ▀▀▀▀ ▀▀▀▀  ▀▀   ▀▀   ▀▀ ▀▀
  5.   ▀▀ ▀▀▀ ▀▀  ▀▀▀▀▀▀▀    ▀▀▀    ╔══ ╦═╗ ╔═╗ ╦═╗ ╦ ╦ ╦ ╔═╗ ╔═╗
  6.   ▀▀  ▀  ▀▀  ▀▀   ▀▀   ▀▀ ▀▀   ║ ╦ ╠╦╝ ╠═╣ ╠═╝ ╠═╣ ║ ║   ╚═╗
  7.   ▀▀     ▀▀  ▀▀   ▀▀  ▀▀   ▀▀  ╚═╝ ╩╚═ ╩ ╩ ╩   ╩ ╩ ╩ ╚═╝ ╚═╝
  8. ───────────────────────────────────────────────────────────────────────────────
  9.   The MAX Graphics GUI Kit is Copyright 1995-Current Larry L. Athey (LA-Soft).
  10.   Color Averaging procedures are courtesy of Sean Price (Rude Dog Software).
  11. ───────────────────────────────────────────────────────────────────────────────
  12. This unit provides facilities for using the GEM format bitmapped fonts in
  13. programs that use the FastGraph graphics library. GEM fonts are used in a
  14. lot of programs such as: NeoSoft products, MAX Graphics products, and any
  15. program written using the GX-Text kit by Genus Microprogramming.
  16.  
  17. GEM fonts may be loaded from files during program execution or they may be
  18. linked into the .EXE file. This requires converting the font to an .OBJ file
  19. using BINOBJ and then creating a .TPU file following the same procedures for
  20. BGI drivers and fonts in Borland's slowpoke BGI interface. Refer to the file
  21. GUI_UNIT.PAS, PROCEDURE LoadGemFonts; for more details.
  22.  
  23. GEM fonts are manipulated by identifiers in the form of pointers.
  24.  
  25. The same color settings and text settings that control the use of BGI fonts
  26. in Borland's slowpoke BGI also control the use of GEM fonts, with these few
  27. differences:
  28.  
  29. A. The normal BGI text settings for font and size are ignored. GEM fonts are
  30.    always drawn at their native size.
  31.  
  32. B. Two text directions in addition to the two available for BGI fonts can
  33.    be specified in a call to GEMFONTU's SetTextDirection. They are:
  34.  
  35.    0 - Horizontal, normal left to right text output.
  36.  
  37.    1 - Vertical, normal bottom to top text output.
  38.  
  39.    2 - Vertical, from top to bottom, rotated 90 degrees clockwise. For this
  40.        direction, left justification means that the top (beginning) of the
  41.        text is at the current position, center justification means that half
  42.        the text is above the current position and half below, and right
  43.        justification means that the bottom (end) of the text is at the
  44.        current position.
  45.  
  46.    3 - Vertical, from top to bottom, without rotation. The meaning of
  47.        justification is the same as for 2. The "Vert" setting is interpreted
  48.        as applying to the horizontal positioning of the characters relative
  49.        to the X coordinate of the current position. TopText causes the left
  50.        edges of the characters to be aligned at X. CenterText causes the
  51.        characters to be centered at X. BottomText causes the right edges of
  52.        the characters to be aligned at X.
  53.  
  54.        NOTE: Due to improper techniques used by some people in creating
  55.              GEM fonts, some of the above modes may not work correctly.
  56.  
  57. ──────────────────────────────────────────────────────────────────────────────}
  58. INTERFACE
  59.  
  60. TYPE
  61.   TWordArray0                 = ARRAY[0..32766] OF WORD;
  62.   PWordArray0                 = ^TWordArray0;
  63.  
  64.   TByteArray0                 = ARRAY[0..65534] OF BYTE;
  65.   PByteArray0                 = ^TByteArray0;
  66.  
  67.   TExtendedGEMFontHeader      = RECORD
  68.   CharacterOffsetTablePtr     : PWordArray0; { Extended portion begins here }
  69.   FontDataPtr                 : PByteArray0;
  70.   AllocatedBytes              : WORD;
  71.   FontID                      : WORD;        { True font header begins here }
  72.   PointSize                   : WORD;
  73.   FontName                    : ARRAY[0..31] OF CHAR;
  74.   LowASCII                    : WORD;
  75.   HighASCII                   : WORD;
  76.   Top                         : INTEGER;
  77.   Ascent                      : INTEGER;
  78.   Half                        : INTEGER;
  79.   Descent                     : INTEGER;
  80.   Bottom                      : INTEGER;
  81.   WidestCharacterWidth        : WORD;
  82.   WidestCellWidth             : WORD;
  83.   LeftOffset                  : INTEGER;
  84.   RightOffset                 : INTEGER;
  85.   Thickness                   : WORD;
  86.   UnderscoreThickness         : WORD;
  87.   LightTextMask               : WORD;
  88.   ItalicTextMask              : WORD;
  89.   Flags                       : WORD;
  90.   HorizontalOffsetTableOffset : LONGINT;
  91.   CharacterOffsetTableOffset  : LONGINT;
  92.   FontDataOffset              : LONGINT;
  93.   SpanWidth                   : WORD;
  94.   Height                      : WORD;
  95.   NextFontOffset              : LONGINT
  96.   END;
  97.  
  98.   PExtendedGEMFontHeader      = ^TExtendedGEMFontHeader;
  99.  
  100. PROCEDURE SetTextDirection(D : WORD);
  101. {^Sets the direction of the text to be displayed. Refer to the description
  102.   in the introductory comments in the above for more details. }
  103.  
  104. FUNCTION GEMTextHeight(GEMFontID : POINTER; TextString : STRING) : WORD;
  105. {^If GEMFontID is a valid identifier of a GEM font, this function returns
  106.   the character height of TextString in pixels when drawn in font GEMFontID.
  107.   (The character height is identical with the cell height of the font.)
  108.   Otherwise the function returns 0. (The function makes no use of TextString,
  109.   since the cell height is an attribute of the font. TextString is included
  110.   simply for symmetry with the TextWidth function.) }
  111.  
  112. FUNCTION GEMTextWidth(GEMFontID : POINTER; TextString : STRING) : WORD;
  113. {^If GEMFontID is a valid identifier of a GEM font, this function returns
  114.   the width of TextString in pixels when drawn in font GEMFontID. Otherwise
  115.   it returns 0. }
  116.  
  117. FUNCTION LoadGEMFont(FontFileName : PathStr; VAR Leading, ErrorCode : WORD) : POINTER;
  118. {^This function loads a GEM font from file FontFileName, sets Leading to the
  119.   cell height of the font and ErrorCode to 0, and returns an identifier for
  120.   the font. If, however, an error occurs during the attempt to load the font,
  121.   the function returns NIL with ErrorCode set to one of these codes:
  122.  
  123.   1 - The file is too large for LoadGEMFont to process.
  124.   2 - There isn't enough heap memory to store the font.
  125.   3 - The file doesn't contain a GEM font. }
  126.  
  127. PROCEDURE OutGEMText(GEMFontID : POINTER; TextString : STRING);
  128. {^If GEMFontID is a valid identifier of a GEM font, TextString is drawn at
  129.   the current position in that font. The text is clipped at the boundaries
  130.   of the screen. The current position is updated only if the direction is
  131.   horizontal and justification is left (if the direction is left to right)
  132.   or right (if the direction is right to left). However, if GEMFontID isn't
  133.   a valid identifier, no action is taken. }
  134.  
  135. PROCEDURE OutGEMTextXY(GEMFontID : POINTER; X, Y : INTEGER; TextString : STRING);
  136. {^Like OutGEMText,except that the text is drawn at position (X,Y) rather than
  137.   the current position. Also, the current position isn't updated under any
  138.   circumstances. }
  139.  
  140. FUNCTION RegisterGEMFont(LinkedGEMFontPtr : POINTER; VAR Leading, ErrorCode : WORD) : POINTER;
  141. {^LinkedGEMFontPtr is the address of the external name of a GEM font that was
  142.   linked into the .EXE file from a unit. The function returns an identifier
  143.   for the font, sets Leading to the cell height of the font, and sets
  144.   ErrorCode to 0. However, if an error is detected, the function returns NIL
  145.   with Leading set to 0 and ErrorCode set to one of these codes:
  146.  
  147.   1 - LinkedGEMFontPtr is NIL.
  148.   2 - There isn't enough heap memory for the control information created
  149.       by the function.
  150.   3 - LinkedGEMFontPtr doesn't point to a GEM font. }
  151.  
  152. PROCEDURE UnloadGEMFont(VAR GEMFontID : POINTER);
  153. {^The GEM font identified by GEMFontID is removed from memory and GEMFontID
  154.   is set to NIL. }
  155.  
  156. {──────────────────────────────────────────────────────────────────────────────}
  157.